<!--  -->
<template>
  <div class="findHome">
    <div class="header">
      <van-icon name="arrow-left" size="18" @click="goBack()" />
      <p>地图找房</p>
      <span></span>
    </div>
    <div class="content">
      <div class="search">
        <select name="" id="">
          <option value="">北京</option>
          <option value="">上海</option>
          <option value="">深圳</option>
        </select>
        <van-search
          v-model="search"
          placeholder="请在这里输入区域/商圈"
          @search="onSearch"
          right-icon="search"
          left-icon=""
        />
      </div>
      <div class="menus">
        <ul>
          <li class="active">
            <img src="../../assets/买房.png" alt="" class="buyHome" />
            <p>买房</p>
          </li>
          <li>
            <img src="../../assets/租房.png" alt="" />
            <p>租房</p>
          </li>
        </ul>
      </div>
      <div class="classify">
        <ul>
          <li @click="goArea()">
            区域<van-icon name="arrow-down" size="13" />
          </li>
          <li @click="goPrice()">
            价格<van-icon name="arrow-down" size="13" />
          </li>
          <li @click="gohouseType()">
            户型<van-icon name="arrow-down" size="13" />
          </li>
          <li>筛选<van-icon name="arrow-down" size="13" /></li>
          <li><van-icon name="sort" /></li>
        </ul>
      </div>
      <!-- 地图 -->
      <baidu-map class="map" :center="center" :zoom="zoom" @ready="handler">
        <bm-scale anchor="BMAP_ANCHOR_TOP_RIGHT"></bm-scale>
        <!-- <bm-city-list anchor="BMAP_ANCHOR_TOP_LEFT"></bm-city-list> -->
        <bm-map-type
          :map-types="['BMAP_NORMAL_MAP', 'BMAP_HYBRID_MAP']"
          anchor="BMAP_ANCHOR_TOP_LEFT"
        ></bm-map-type>
        <bm-navigation anchor="BMAP_ANCHOR_TOP_RIGHT"></bm-navigation>
        <bm-geolocation
          anchor="BMAP_ANCHOR_BOTTOM_RIGHT"
          :showAddressBar="true"
          :autoLocation="true"
        ></bm-geolocation>
      </baidu-map>
    </div>
  </div>
</template>

<script>
export default {
  // 组件状态值
  data() {
    return {
      search: "",
      center: { lng: 0, lat: 0 },
      zoom: 3,
    };
  },
  // 计算属性
  computed: {},
  // 组件方法
  methods: {
    //返回上一级
    goBack() {
      this.$router.go(-1);
    },
    //分页
    onSearch() {},

    handler({ BMap, map }) {
      console.log(BMap, map);
      this.center.lng = 121.701;
      this.center.lat = 30.877;
      this.zoom = 15;
    },
  },
  /**
   * 组件实例创建完成，属性已绑定，但DOM还未生成，$ el属性还不存在
   */
  created() {},
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<!--使用了scoped属性之后，父组件的style样式将不会渗透到子组件中，-->
<!--然而子组件的根节点元素会同时被设置了scoped的父css样式和设置了scoped的子css样式影响，-->
<!--这么设计的目的是父组件可以对子组件根元素进行布局。-->
<style lang="scss" scoped>
.findHome {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.header {
  width: 100%;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 18px;
  color: #fff;
  background: #4381e6;
  padding: 0 15px;
}
.search {
  width: 100%;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 10px;
  .van-search__content {
    border: 1px solid #ddd;
  }
  select {
    width: 55px;
    border: 0;
    outline: 0;
  }
  p {
    font-size: 15px;
  }
}
.content {
  border-left: 1px solid #000;
  border-right: 1px solid #000;
}
.menus {
  width: 100%;
  ul {
    display: flex;
    justify-content: space-around;
    align-items: center;
    text-align: center;
    .active {
      color: orange;
    }
    img {
      width: 80px;
      margin-bottom: 10px;
    }
    li:nth-child(2) {
      img {
        width: 95px;
      }
    }
  }
}
.classify {
  width: 100%;
  border-top: 1px solid #000;
  border-bottom: 1px solid #000;
  ul {
    display: flex;
    justify-content: space-around;
    line-height: 40px;
    .van-icon {
      margin-left: 3px;
    }
  }
}
.map {
  width: 100%;
  height: 400px;
}
</style>
